/*
 * This file is part of JaTeCS.
 *
 * JaTeCS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JaTeCS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JaTeCS.  If not, see <http://www.gnu.org/licenses/>.
 *
 * The software has been mainly developed by (in alphabetical order):
 * - Andrea Esuli (andrea.esuli@isti.cnr.it)
 * - Tiziano Fagni (tiziano.fagni@isti.cnr.it)
 * - Alejandro Moreo Fernández (alejandro.moreo@isti.cnr.it)
 * Other past contributors were:
 * - Giacomo Berardi (giacomo.berardi@isti.cnr.it)
 */

package it.cnr.jatecs.clustering.kmeans;

import it.cnr.jatecs.clustering.interfaces.IDocumentClusterizerRuntimeCustomizer;
import it.cnr.jatecs.indexing.similarity.EuclideanDistance;
import it.cnr.jatecs.indexing.similarity.ISimilarityFunction;

public class KMeansDocumentCustomizer implements IDocumentClusterizerRuntimeCustomizer {

    /**
     * The number of clusters to divide the entire domain space.
     */
    protected int _k;


    /**
     * The similarity function used.
     */
    protected ISimilarityFunction _similarity;


    /**
     * The algorithm convergence criterium to use.
     */
    IDocumentConvergeCriterion _convCriteria;


    public KMeansDocumentCustomizer() {
        _k = 10;
        _similarity = new EuclideanDistance();
        _convCriteria = new NoReassignmentDocumentConvergeCriterion();
    }

    /**
     * Get the number of clusters that must be generated by algorithm.
     *
     * @return The number of clusters.
     */
    public int getNumberOfClusters() {
        return _k;
    }

    /**
     * Set the number of clusters to be generated by algorithm.
     *
     * @param k The number of clusters to generate.
     */
    public void setNumberOfClusters(int k) {
        if (k <= 0)
            k = 90;

        _k = k;
    }

    public ISimilarityFunction getSimilarityFunction() {
        return _similarity;
    }

    public void setSimilarityFunction(ISimilarityFunction func) {
        _similarity = func;
    }

    public IDocumentConvergeCriterion getConvergenceCriterion() {
        return _convCriteria;
    }

    public void setConvergenceCriterion(IDocumentConvergeCriterion criterion) {
        _convCriteria = criterion;
    }


}
